#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2018/10/18 13:36
@desc
"""

from sqlalchemy import Column, String
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://pyspd_admin:pyspd_admin_1Q@192.168.100.181:1921/spd_mgr'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)


class AdminTest(db.Model):
    __tablename__ = 'admin'
    username = Column(db.String(128), primary_key=True)
    description = Column(db.String(1024), unique=True)
    password = Column(db.String(256), unique=True)

    def __repr__(self):
        """  这个类似java的 toString方法 """
        return '%s(%r)[%s]:%s' % (self.__class__.__name__, self.username, self.description, self.password)


if __name__ == '__main__':
    # db.create_all()
    aa = AdminTest.query.filter_by(username='admin').first()
    print(aa)
    # Base.metadata.create_all(engine)
